<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的工单</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <include file="Index/common_css"/>
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/common/css/dataTables.bootstrap.css" rel="stylesheet">
    <!--分页样式-->
    <style type="text/css">
        div.green-black{padding:3px;margin:3px;text-align:center;}
        div.green-black a{border:#2c2c2c 1px solid;padding:2px 5px;background: #2c2c2c;color:#fff;margin:0 2px 0 0;text-decoration:none;}
        div.green-black a:hover{border:#aad83e 1px solid;background:#aad83e;color:#fff;}
        div.green-black a:active{border:#aad83e 1px solid;background:#aad83e;color:#fff;}
        div.green-black span.current{border:#aad83e 1px solid;padding:2px 5px;font-weight:bold;background:#aad83e;color:#fff;margin:0 2px 0 0;}
        div.green-black span.disabled{border:#f3f3f3 1px solid;padding:2px 5px;color:#ccc;margin:0 2px 0 0;}
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row">
        <div class="col-sm-12">

            <div class="ibox">
                <div class="ibox-title">
                    <h5>我的 工单</h5>
                    <div class="ibox-tools">
                        <a href="WorkOrder_add.html" class="btn btn-primary btn-xs">创建新工单</a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row m-b-sm m-t-sm">
                        <div class="col-md-1">
                            <button type="button" id="loading-example-btn" class="btn btn-white btn-sm"><i class="fa fa-refresh"></i> 刷新</button>
                        </div>
                        <form action="MyWorkOrder.html" method="post">
                            <div class="col-md-11">
                                <div class="input-group">
                                    <input type="text" placeholder="请输入工单名称" class="input-sm form-control" required="">
                                    <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
                                </span>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="project-list">

                        <table class="table table-hover">
                            <tbody>
                            <foreach name="list" item="li">
                                <tr>
                                    <td class="project-status">
                                        <if condition="($li.state eq 1) or($li.state eq 4)">
                                            <span class="label label-default">{$li.sys_state}</span>
                                            <else/>
                                            <span class="label label-primary">{$li.sys_state}</span>
                                        </if>
                                    </td>
                                    <td class="project-status">
                                        <span class="label">{$li.type}</span>
                                    </td>
                                    <td class="project-title">
                                        <a href="javascript:;">{$li.title}</a>
                                        <br/>
                                        <small>创建于 {$li.time}</small>
                                    </td>
                                    <td class="project-completion">
                                        <small>当前进度：{$li.speed}</small>
                                        <div class="progress progress-mini">
                                            <div style="width: {$li.speed};" class="progress-bar"></div>
                                        </div>
                                    </td>
                                    <td class="project-people">
                                        <if condition="$li['file'] neq 'Uploads/'">
                                            <a href="javascript:;"><img alt="image" class="img-circle" src="__ROOT__/{$li.file}"></a>
                                        </if>
                                        <if condition="$li['file2'] neq 'Uploads/'">
                                            <a href="javascript:;"><img alt="image" class="img-circle" src="__ROOT__/{$li.file2}"></a>
                                        </if>
                                        <if condition="$li['file3'] neq 'Uploads/'">
                                            <a href="javascript:;"><img alt="image" class="img-circle" src="__ROOT__/{$li.file3}"></a>
                                        </if>
                                    </td>
                                    <td class="project-actions">
                                        <a href="__MODULE__/WorkOrder/work_order_detail/id/{$li.id}" class="btn btn-white btn-sm"><i class="fa fa-search-plus"></i> 查看 </a>

                                        <if condition="$li.state eq 1">
                                            <a href="javascript:;" onclick="Revoke(this,'{$li.id}')" class="btn btn-white btn-sm"><i class="fa fa-pencil"></i> 撤销工单 </a>
                                          <elseif   condition="$li.state eq 4"/>
                                            <a href="javascript:;"  class="btn btn-white btn-sm"><i class="fa fa-pencil"></i> 工单已撤销 </a>
                                        </if>
                                    </td>
                                </tr>
                            </foreach>

                            </tbody>
                        </table>
                        <div class="green-black">{$page}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<include file="Index/common_js"/>
<!-- Peity -->
<!--<script src="__PUBLIC__/admin/js/plugins/peity/jquery.peity.min.js"></script>-->
<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/admin/js/plugins/layer/laydate/laydate.js"></script>
<script src="__PUBLIC__/admin/js/plugins/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/admin/js/plugins/validate/messages_zh.min.js"></script>
<script>
    $(document).ready(function(){
        $('#loading-example-btn').click(function () {
            btn = $(this);
            simpleLoad(btn, true)
            simpleLoad(btn, false)
        });
    });

    function Revoke(obj,id) {
        layer.confirm('确认要撤销吗？',function(){
            var index = layer.load(0, {shade: false});
            if(id){
                $.ajax({
                    type:"POST",
                    url:"__MODULE__/WorkOrder/Revoke_order",
                    dataType:'json',
                    data:{id:id},
                    success:function(data){
                        layer.close(index);
                        if(data.status==1){
                            layer.msg(data.msg);setTimeout(function () {location.reload();}, 1000);
                        }else if(data.status==0){
                            layer.error(data.error);
                        }else{
                            layer.msg('网络错误',{icon: 2, time: 2000});
                        }
                    },error:function(err){
                        layer.close(index);
                        layer.msg('error:网络错误',{icon: 2, time: 2000});
                    }
                });
            }else{
                layer.msg('error');
            }
        })
    }

    function simpleLoad(btn, state) {
        if (state) {
            btn.children().addClass('fa-spin');
            btn.contents().last().replaceWith(" Loading");
        } else {
            setTimeout(function () {
                btn.children().removeClass('fa-spin');
                btn.contents().last().replaceWith(" Refresh");
                location.reload();
            }, 2000);
        }
    }
</script>
</body>
</html>
